<?php
namespace app\blog\controller;

use app\blog\controller\Front;

class Index extends Front
{
    protected function initialize()
    {
        parent::initialize(); 
    }
    
    public function index()
    {
        $this->site['title'] = $this->seoReplace(config('page.index_title'),true);
        $this->site['keywords'] = $this->seoReplace(config('page.index_keywords'));
        $this->site['description'] = $this->seoReplace(config('page.index_description'));
        $this->assign($this->pageList());
        $this->assign($this->site);
        return $this->fetch();
    }

    //分页查询
    private function pageList()
    {
        $sortField = xfEmpty(config('page.index_sort'),'detail_id');
        $args = [
            'cache' => config('cache.expire_items'),
            'order' => [
                'detail_top' => 'desc',
                $sortField  => 'desc',
            ],
            'where' => [
                ['detail_status','eq','normal'],
            ],
        ];
        //查询数据
        return model('blog/Index','loglic')->allPage($args,intval(config('page.index_limit')),$this->site['page'],intval(config('page.index_total')),xfUrlPath('blog/index/index',$this->query));
    }
}